import { defineStore } from 'pinia';

const useBooleanStore = defineStore('booleanStore', {
  state: () => ({
    num: 0,
    num2: 0,
    num3: 0,
    num4: 0,
    num5: 0,
    num6: 0,
    num7: 0,
    boolValue: false,
    boolValue2: false,
    boolValue3: false,
    boolValue4: false,
    versionVisible: false,
    showMenu: false,
    update: false,
    pageNum: 0,
    pageSize: 0,
    account: '',
    user: '',
    role: [] as any[],
    permissions: [] as any[],
    users: [] as any[],
    list: [] as any[],
    listTwo: [] as any[],
    listThree: [] as any[],
    listFour: [] as any[],
    listFive: [] as any[],
    partReturnList: [] as any[],
    finishReturnList: [] as any[],
    standardReturnList: [] as any[],
    materialList: [] as any[],
    partList: [] as any[],
    finishList: [] as any[],
    standardList: [] as any[],
    logList: [] as any[],
    row: {} as any,
    // 对象
    info1: '' as string,
    info2: '' as string,
    // color: 'rgb(223,223,223)',
    // color: 'rgb(226,226,226)',
    color: 'rgb(210,210,210)',
    borderRadius: '0px',
    // 分拣操作的全局数据状态
    sortingList: [] as any[],
    sortingIsTrue: false,
    consoleId: '' as string,

    // 当前托盘
    toolList: [] as any[],
    // 当前缓存箱
    workBinList: [] as any[],
    // les
    // 控制les新增的弹框
    isOpen: false as boolean,
    isName: '' as string,
  }),
  actions: {
    // 用在les页面的监听新增弹框
    setIsOpen(name: string) {
      this.isName = name;
      this.isOpen = !this.isOpen;
    },

    // 当前托盘的方法
    setToolList(list: any[]) {
      this.toolList = [];
      this.toolList = list;
    },
    // 当前缓存箱的方法
    setWorkBinList(list: any[]) {
      this.workBinList = [];
      this.workBinList = list;
    },
    // 工作台id
    setConsoleId(id: string) {
      this.consoleId = id;
    },
    // 分拣操作的方法
    setSortingList(list: any[]) {
      this.sortingList = [];
      this.sortingList = list;
    },
    setSortingIsTrue() {
      this.sortingIsTrue = !this.sortingIsTrue;
    },
    // 用在一些页面的监听新增弹框
    toggleBool(num: number) {
      this.num = num;
      this.boolValue = !this.boolValue;
    },
    // 用在一些页面的监听修改弹框
    toggleBool2(num: number) {
      this.num2 = num;
      this.boolValue2 = !this.boolValue2;
    },
    // 用在一些页面的监听查看缓存箱(可能有些其他地方也需要用到)
    toggleBool3(num: number) {
      this.num3 = num;
      this.boolValue3 = !this.boolValue3;
    },
    toggleBool4(num: number) {
      this.num4 = num;
      this.boolValue4 = !this.boolValue4;
    },
    // 版本号弹框
    toggleVersionVisible() {
      this.versionVisible = !this.versionVisible;
    },
    // 在用户信息页面，用于监听用户信息
    setUser(account: string, user: string) {
      this.account = account;
      this.user = user;
    },
    // 用于监听更新按钮
    watchUpdate(num: number) {
      this.num6 = num;
      this.update = !this.update;
    },
    // 用于分页
    setPage(pageNum: number, pageSize: number, num: number) {
      this.num5 = num;
      this.pageNum = pageNum;
      this.pageSize = pageSize;
    },
    // 用于监听角色权限
    setRole(role: any[], permissions: any[]) {
      this.role = [];
      this.permissions = [];
      this.role.push(role);
      this.permissions.push(permissions);
    },
    // 用于监听用户信息
    setUsers(users: any[], list: any[]) {
      this.users = [];
      this.list = [];
      this.users.push(users);
      this.list.push(list);
    },
    // 修改接口传值
    setRow(row: any, num?: number) {
      this.num7 = num !== undefined && num !== null ? num : 0;
      this.row = [];
      this.row = row;
    },
    // 修改接口传值
    setList(list: any, num: number) {
      this.num7 = num;
      this.list = [];
      this.list.push(list);
    },
    // 修改接口传值
    setListTwo(list: any, num?: number) {
      this.num7 = num !== undefined && num !== null ? num : 0;
      this.listTwo = [];
      this.listTwo.push(list);
    },
    // 立体库维护选中的值存储
    setListThree(list: any) {
      this.listThree = [];
      this.listThree.push(list);
    },
    // 物料入库选中的值存储
    setMaterialList(list: any) {
      this.materialList = [];
      this.materialList.push(list);
    },
    // 工作包分拣选中的值存储
    setListFour(list: any) {
      this.listFour = [];
      this.listFour.push(list);
    },
    // 协调单选中的值存储
    setListFive(list: any) {
      this.listFive = [];
      this.listFive.push(list);
    },
    // 零件退回选中的值存储
    setPartReturn(list: any) {
      this.partReturnList = [];
      this.partReturnList.push(list);
    },
    // 成品退回选中的值存储
    setFinishReturn(list: any) {
      this.finishReturnList = [];
      this.finishReturnList.push(list);
    },
    // 标准件退回选中的值存储
    setStandardReturn(list: any) {
      this.standardReturnList = [];
      this.standardReturnList.push(list);
    },
    // 修改零件传值
    setPartList(list: any) {
      this.partList = [];
      this.partList.push(list);
    },
    // 修改成品传值
    setFinishList(list: any) {
      this.finishList = [];
      this.finishList.push(list);
    },
    // 修改标准件传值
    setStandardList(list: any) {
      this.standardList = [];
      this.standardList.push(list);
    },

    // 修改标准件传值
    setLogList(list: any) {
      this.logList = [];
      this.logList.push(list);
    },
    // 清空菜单内容
    toggleMenu() {
      this.showMenu = !this.showMenu;
    },
    // 传递俩个字符串
    setInfo(item1: string, item2: string) {
      this.info1 = '';
      this.info2 = '';
      this.info1 = item1;
      this.info2 = item2;
    },
  },
});

export default useBooleanStore;
